package com.example.boot1.filterInterceptor;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

@Configuration
public class FilterRegistrationConfig {
    @Bean
    public FilterRegistrationBean<Filter> filter1(){
        FilterRegistrationBean<Filter>  filterRegistrationBean=  new FilterRegistrationBean<>();
        //设置过滤器名称
        filterRegistrationBean.setFilter(new BulkFilter1());
        //配置过滤规则
        filterRegistrationBean.addUrlPatterns("/*");
        //order的数值越小，则优先级越高
        filterRegistrationBean.setOrder(2);
        return filterRegistrationBean;
    }

    @Bean
    public  FilterRegistrationBean<Filter> filter2(){
        FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
        //设置过滤器名称
        filterRegistrationBean.setFilter(new BulkFilter2());
        //配置过滤规则
        filterRegistrationBean.addUrlPatterns("/*");
        //filter数值小，优先级越高
        filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }


}
